package cz.proks.easyhelpdesk.gwt.event;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

import cz.proks.easyhelpdesk.api.model.Category;

public class CategorySaveEvent extends GwtEvent<CategorySaveEvent.Handler>{
    public final static Type<CategorySaveEvent.Handler> TYPE = new Type<CategorySaveEvent.Handler>();
    
    public static interface Handler extends EventHandler {
        void onCategorySave(CategorySaveEvent event);
    }

    private final Category category;

    public CategorySaveEvent(Category category) {
        super();
        this.category = category;
    }
    
    public static void fireEvent(HasCategorySaveHandlers source, Category category) {
        source.fireEvent(new CategorySaveEvent(category));
    }

    public Category getCategory() {
        return category;
    }

    @Override
    public com.google.gwt.event.shared.GwtEvent.Type<Handler> getAssociatedType() {
        return TYPE;
    }

    @Override
    protected void dispatch(Handler handler) {
        handler.onCategorySave(this);
    }    
}
